package com.itheima.threadpool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/*
使用工具类获取 最大数量的线程池
 */
public class Demo02 {


    public static void main(String[] args) throws InterruptedException {

        ExecutorService es = Executors.newFixedThreadPool(10);
        ThreadPoolExecutor pool= (ThreadPoolExecutor) es;//
        System.out.println("初始时"+pool.getPoolSize());


        for (int  i=0;i<100;i++) {
            pool.submit(()->{
                for (int j = 0; j < 10; j++) {
                    System.out.println(Thread.currentThread().getName()+"@@@"+j);
                }
            });
        }
        Thread.sleep(2000);
        System.out.println("结束时"+pool.getPoolSize());

    }

}
